#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 1e6 + 10, INF = 0x3f3f3f3f;

ll n;
ll x1, y1, z1;
ll x2, y2, z2;

ll f(ll x1, ll y1, ll z1, ll x2, ll y2, ll z2)
{
    ll ans = 0;
    ll t1 = min(x2, y1), t2 = min(y2, z1), t3 = min(z2, x1);

    ans = t1 + t2 + t3;
    x2 -= t1, y1 -= t1;
    y2 -= t2, z1 -= t2;
    z2 -= t3, x1 -= t3;

    t1 = min(x1, x2), t2 = min(y1, y2), t3 = min(z1, z2);
    x1 -= t1, x2 -= t1;
    y1 -= t2, y2 -= t2;
    z1 -= t3, z2 -= t3;

    ans -= min(x2, z1) + min(y2, x1) + min(z2, y1);
    return ans;
}

void solve()
{
    cin >> n >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
    cout << f(x2, y2, z2, x1, y1, z1) << ' ';
    cout << -f(x1, y1, z1, x2, y2, z2) << '\n';
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    cin >> T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}